<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>API documentation &mdash; ecg_qc 1.0.0 documentation</title>
      <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
    <script src="_static/js/theme.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="References" href="references.html" />
    <link rel="prev" title="Welcome to ecg_qc’s documentation!" href="index.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
            <a href="index.html" class="icon icon-home"> ecg_qc
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">API documentation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#ecgqc-class">EcgQc class</a></li>
<li class="toctree-l2"><a class="reference internal" href="#frequency-distribution-sqi">Frequency distribution sqi</a></li>
<li class="toctree-l2"><a class="reference internal" href="#power-spectrum-sqi">Power spectrum sqi</a></li>
<li class="toctree-l2"><a class="reference internal" href="#r-r-interval-sqi">R-R interval sqi</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="references.html">References</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">ecg_qc</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
      <li>API documentation</li>
      <li class="wy-breadcrumbs-aside">
            <a href="_sources/ecg_qc.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="api-documentation">
<h1>API documentation<a class="headerlink" href="#api-documentation" title="Permalink to this headline"></a></h1>
<p>ecg_qc is a python library that classifies ECG signal to 0 = bad quality and 1 = good quality.</p>
<p>0 = bad quality corresponds to an ECG signal containing baseline shift, hight frequency noise which disturbs the QRS analysis.</p>
<p>1 = good quality corresponds to a clean ECG signal where the QRS can be perfectly detected.</p>
<section id="ecgqc-class">
<h2>EcgQc class<a class="headerlink" href="#ecgqc-class" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="ecg_qc.ecg_qc.EcgQc">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">ecg_qc.ecg_qc.</span></span><span class="sig-name descname"><span class="pre">EcgQc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model_file</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'rfc_norm_2s.pkl'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sampling_frequency</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">256</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">normalized</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ecg_qc/ecg_qc.html#EcgQc"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.ecg_qc.EcgQc" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>This class determines the quality of an ECG segment, usually lasting
several seconds. It computes SQIs (Signal Quality Indicator) and use them
in a pre-trained model to predict the quality:</p>
<blockquote>
<div><ul class="simple">
<li><p>1 : good quality</p></li>
<li><p>0 : bad quality</p></li>
</ul>
</div></blockquote>
<dl class="py attribute">
<dt class="sig sig-object py" id="ecg_qc.ecg_qc.EcgQc.model_file">
<span class="sig-name descname"><span class="pre">model_file</span></span><a class="headerlink" href="#ecg_qc.ecg_qc.EcgQc.model_file" title="Permalink to this definition"></a></dt>
<dd><p>Trained model to load to predict quality. Can be the name of included
pre-trained model or a path to an other model.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p>str</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="ecg_qc.ecg_qc.EcgQc.sampling_frequency">
<span class="sig-name descname"><span class="pre">sampling_frequency</span></span><a class="headerlink" href="#ecg_qc.ecg_qc.EcgQc.sampling_frequency" title="Permalink to this definition"></a></dt>
<dd><p>Sampling frequency of the input ECG signal. Used for several SQI
computing</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="ecg_qc.ecg_qc.EcgQc.normalized">
<span class="sig-name descname"><span class="pre">normalized</span></span><a class="headerlink" href="#ecg_qc.ecg_qc.EcgQc.normalized" title="Permalink to this definition"></a></dt>
<dd><p>If True, will normalise input ecg signal</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="ecg_qc.ecg_qc.EcgQc.compute_sqi_scores">
<span class="sig-name descname"><span class="pre">compute_sqi_scores</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ecg_qc/ecg_qc.html#EcgQc.compute_sqi_scores"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.ecg_qc.EcgQc.compute_sqi_scores" title="Permalink to this definition"></a></dt>
<dd><p>Computes SQIs from an ECG signal segment</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="ecg_qc.ecg_qc.EcgQc.predict_quality">
<span class="sig-name descname"><span class="pre">predict_quality</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sqi_scores</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ecg_qc/ecg_qc.html#EcgQc.predict_quality"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.ecg_qc.EcgQc.predict_quality" title="Permalink to this definition"></a></dt>
<dd><p>From a list of SQIs, predict the quality of a related ECG segment</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="ecg_qc.ecg_qc.EcgQc.get_signal_quality">
<span class="sig-name descname"><span class="pre">get_signal_quality</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ecg_qc/ecg_qc.html#EcgQc.get_signal_quality"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.ecg_qc.EcgQc.get_signal_quality" title="Permalink to this definition"></a></dt>
<dd><p>From an ECG signal segment, directly returns the quality</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="id0">
<span class="sig-name descname"><span class="pre">compute_sqi_scores</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span></span></span><a class="reference internal" href="_modules/ecg_qc/ecg_qc.html#EcgQc.compute_sqi_scores"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#id0" title="Permalink to this definition"></a></dt>
<dd><p>From an ECG Signal segment, computes 6 SQI scores (q_sqi, c_sqi, s_sqi,
k_sqi, p_sqi, bas_sqi)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>sqi_scores</strong> – SQI scores related to input ECG segment</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>list</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="id1">
<span class="sig-name descname"><span class="pre">get_signal_quality</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="reference internal" href="_modules/ecg_qc/ecg_qc.html#EcgQc.get_signal_quality"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#id1" title="Permalink to this definition"></a></dt>
<dd><p>From an ECG segment signal, use pre-trained model to compute
the quality of the signal. This method is a shortcut to using
compute_sqi_scores then predict quality.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>prediction</strong> – The signal quality predicted by the model</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="id2">
<span class="sig-name descname"><span class="pre">predict_quality</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sqi_scores</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="reference internal" href="_modules/ecg_qc/ecg_qc.html#EcgQc.predict_quality"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#id2" title="Permalink to this definition"></a></dt>
<dd><p>From an ECG segment SQI scores, use pre-trained model to compute
the quality of the signal.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>sqi_scores</strong> (<em>list</em><em>(</em><em>list</em><em>)</em>) – SQI scores related to input ECG segment</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>prediction</strong> – The signal quality predicted by the model</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>
<section id="frequency-distribution-sqi">
<h2>Frequency distribution sqi<a class="headerlink" href="#frequency-distribution-sqi" title="Permalink to this headline"></a></h2>
<p><strong>Skewness</strong></p>
<p>Skewness is a measure of the asymmetry of a distribution around its mean. It can be negative, null or positive. To describe the skewness, we compute the Pearson’s moment coefficient, corresponding to the third standardized moment.</p>
<a class="reference internal image-reference" href="_images/neg_pos_skew.png"><img alt="_images/neg_pos_skew.png" src="_images/neg_pos_skew.png" style="width: 500px;" /></a>
<p><a class="reference external" href="https://en.wikipedia.org/wiki/Skewness#Pearson's_moment_coefficient_of_skewness">https://en.wikipedia.org/wiki/Skewness#Pearson’s_moment_coefficient_of_skewness</a></p>
<dl class="simple">
<dt>When we have</dt><dd><ul class="simple">
<li><p>Symetrical distribution, the skewness coef = 0</p></li>
<li><p>Asymetrical distribution skewed on the left, the skewness coef is &gt; 0</p></li>
<li><p>Asymetrical distribution skewed on the right, the skewness coef is &gt; 0</p></li>
</ul>
</dd>
</dl>
<p><strong>Kurtosis</strong></p>
<p>Kurtosis is a measure tailedness of the distribution around its mean. To describe the kurtosis, we compute the Pearson’s moment coefficient, corresponding to the fourth scaled moment.
The excess kurtosis is defined as the kurtosis minus 3 (3 being the kurtosis coef of a normal distribution). The kurtosis can be positive or negative.</p>
<p>High excess kurtosis means that there are outliers far away from the distribution’s mean.</p>
<blockquote>
<div><a class="reference internal image-reference" href="_images/kurtosis.png"><img alt="_images/kurtosis.png" src="_images/kurtosis.png" style="width: 500px;" /></a>
</div></blockquote>
<p><a class="reference external" href="https://www.statext.com/android/kurtosis.html">https://www.statext.com/android/kurtosis.html</a></p>
<dl class="simple">
<dt>When we have</dt><dd><ul class="simple">
<li><p>Mesokurtic distribution (black) : excess kurtosis = 0</p></li>
<li><p>Leptokurtic distribution (green) : excess kurtosis &gt; 0</p></li>
<li><p>Platykurtic distribution (blue) : excess kurtosis &lt; 0</p></li>
</ul>
</dd>
</dl>
<span class="target" id="module-ecg_qc.sqi_computing.sqi_frequency_distribution"></span><dl class="py function">
<dt class="sig sig-object py" id="ecg_qc.sqi_computing.sqi_frequency_distribution.ksqi">
<span class="sig-prename descclassname"><span class="pre">ecg_qc.sqi_computing.sqi_frequency_distribution.</span></span><span class="sig-name descname"><span class="pre">ksqi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="reference internal" href="_modules/ecg_qc/sqi_computing/sqi_frequency_distribution.html#ksqi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.sqi_computing.sqi_frequency_distribution.ksqi" title="Permalink to this definition"></a></dt>
<dd><p>Computes the excess kurtosis sqi.</p>
<p>Kurtosis represents how spread a distribution is.</p>
<ul class="simple">
<li><p>Mesokurtic distribution : excess kurtosis = 0</p></li>
<li><p>Leptokurtic distribution : excess kurtosis &gt; 0</p></li>
<li><p>Platykurtic distribution : excess kurtosis &lt; 0</p></li>
</ul>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>k_sqi_score</strong> – rounded excess kurtosis sqi score</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="ecg_qc.sqi_computing.sqi_frequency_distribution.ssqi">
<span class="sig-prename descclassname"><span class="pre">ecg_qc.sqi_computing.sqi_frequency_distribution.</span></span><span class="sig-name descname"><span class="pre">ssqi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="reference internal" href="_modules/ecg_qc/sqi_computing/sqi_frequency_distribution.html#ssqi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.sqi_computing.sqi_frequency_distribution.ssqi" title="Permalink to this definition"></a></dt>
<dd><p>Computes the skewness sqi.</p>
<p>Skewness represents how asymetrical a distribution is.</p>
<ul class="simple">
<li><p>Symetrical distribution : skewness = 0</p></li>
<li><p>Asymetrical distribution skewed on the left : skewness &lt; 0</p></li>
<li><p>Asymetrical distribution skewed on the right : skewness &gt; 0</p></li>
</ul>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>s_sqi_score</strong> – rounded skewness sqi score</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="power-spectrum-sqi">
<h2>Power spectrum sqi<a class="headerlink" href="#power-spectrum-sqi" title="Permalink to this headline"></a></h2>
<p><strong>Power spectrum distribution of QRS Wave</strong></p>
<p>The energy of the QRS wave is computed on frequencies ranging from 5Hz to 15Hz (the energy of the QRS wave is concentrated in a frequency band centered at 10 Hz and is 10 Hz in width),
the energy of the ECG signal is computed on frequencies ranging from 5Hz to 40Hz.
.</p>
<p>If interference exists, the high-frequency component increases, and pSQI decreases.</p>
<p>Let’s take the following clean ECG signal. The computed psqi = 0.07.</p>
<a class="reference internal image-reference" href="_images/clean_ecg_signal.png"><img alt="_images/clean_ecg_signal.png" src="_images/clean_ecg_signal.png" style="width: 500px;" /></a>
<p>Let’s now take an ECG with high frequencies noise. The computed psqi = 0.3.</p>
<a class="reference internal image-reference" href="_images/noise_ecg_signal.png"><img alt="_images/noise_ecg_signal.png" src="_images/noise_ecg_signal.png" style="width: 500px;" /></a>
<p><strong>Relative power in the Baseline</strong></p>
<p>It corresponds to the ratio of the energy of the QRS wave and the energy of the ECG signal.
The energy of the baseline is computed on frequencies ranging from 0Hz to 1Hz, the energy of the ECG signal is computed on
frequencies ranging from 0Hz to 40Hz.</p>
<p>If there is no baseline drift interference, the basSQI value is close to 1. An abnormal shift in the baseline causes the bassqi to decrease.</p>
<p>Let’s take the following clean ECG signal. The computed bassqi = 0.99.</p>
<a class="reference internal image-reference" href="_images/clean_ecg_signal.png"><img alt="_images/clean_ecg_signal.png" src="_images/clean_ecg_signal.png" style="width: 500px;" /></a>
<p>Let’s now take an ECG with important baseline shift. The computed bassqi = 0.97.</p>
<a class="reference internal image-reference" href="_images/baseline_shift_ecg_signal.png"><img alt="_images/baseline_shift_ecg_signal.png" src="_images/baseline_shift_ecg_signal.png" style="width: 500px;" /></a>
<span class="target" id="module-ecg_qc.sqi_computing.sqi_power_spectrum"></span><dl class="py function">
<dt class="sig sig-object py" id="ecg_qc.sqi_computing.sqi_power_spectrum.bassqi">
<span class="sig-prename descclassname"><span class="pre">ecg_qc.sqi_computing.sqi_power_spectrum.</span></span><span class="sig-name descname"><span class="pre">bassqi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sampling_frequency</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="reference internal" href="_modules/ecg_qc/sqi_computing/sqi_power_spectrum.html#bassqi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.sqi_computing.sqi_power_spectrum.bassqi" title="Permalink to this definition"></a></dt>
<dd><p>Computes the relative power in the Baseline.</p>
<p>It corresponds to the ratio of the energy of the QRS wave and the energy of
the ECG signal. The energy of the baseline is computed on frequencies
ranging from 0Hz to 1Hz, the energy of the ECG signal is computed on
frequencies ranging from 0Hz to 40Hz.</p>
<p>If there is no baseline drift interference, the basSQI value is close to 1.
An abnormal shift in the baseline causes the bassqi to decrease.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p></li>
<li><p><strong>sampling_frequency</strong> (<em>list</em>) – Input ecg sampling frequency</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>bas_sqi_score</strong></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="ecg_qc.sqi_computing.sqi_power_spectrum.psqi">
<span class="sig-prename descclassname"><span class="pre">ecg_qc.sqi_computing.sqi_power_spectrum.</span></span><span class="sig-name descname"><span class="pre">psqi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sampling_frequency</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="reference internal" href="_modules/ecg_qc/sqi_computing/sqi_power_spectrum.html#psqi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.sqi_computing.sqi_power_spectrum.psqi" title="Permalink to this definition"></a></dt>
<dd><p>Computes the power spectrum Distribution of QRS Wave.</p>
<p>It corresponds to the ratio of the energy of the QRS wave and the energy of
the ECG signal. The energy of the QRS wave is computed on frequencies
ranging from 5Hz to 15Hz, the energy of the ECG signal is computed on
frequencies ranging from 5Hz to 40Hz.</p>
<p>If interference exists, the high-frequency component increases, and pSQI
decreases.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p></li>
<li><p><strong>sampling_frequency</strong> (<em>list</em>) – Input ecg sampling frequency</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>p_sqi_score</strong></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="r-r-interval-sqi">
<h2>R-R interval sqi<a class="headerlink" href="#r-r-interval-sqi" title="Permalink to this headline"></a></h2>
<p>An ECG signal is a periodic signal composed of P, Q, R and T wave.</p>
<a class="reference internal image-reference" href="_images/pqrst_wave.jpg"><img alt="_images/pqrst_wave.jpg" src="_images/pqrst_wave.jpg" style="width: 500px;" /></a>
<p><a class="reference external" href="https://www.aclsmedicaltraining.com/basics-of-ecg/">https://www.aclsmedicaltraining.com/basics-of-ecg/</a></p>
<p>R wave has the maximum amplitude and most obvious characteristic so we often characterize the ECG signal by R wave detection.</p>
<span class="target" id="module-ecg_qc.sqi_computing.sqi_rr_intervals"></span><dl class="py function">
<dt class="sig sig-object py" id="ecg_qc.sqi_computing.sqi_rr_intervals.compute_qrs_frames_correlation">
<span class="sig-prename descclassname"><span class="pre">ecg_qc.sqi_computing.sqi_rr_intervals.</span></span><span class="sig-name descname"><span class="pre">compute_qrs_frames_correlation</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qrs_frames_1</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qrs_frames_2</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sampling_frequency</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">matching_qrs_frames_tolerance</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">50</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="reference internal" href="_modules/ecg_qc/sqi_computing/sqi_rr_intervals.html#compute_qrs_frames_correlation"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.sqi_computing.sqi_rr_intervals.compute_qrs_frames_correlation" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="ecg_qc.sqi_computing.sqi_rr_intervals.csqi">
<span class="sig-prename descclassname"><span class="pre">ecg_qc.sqi_computing.sqi_rr_intervals.</span></span><span class="sig-name descname"><span class="pre">csqi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sampling_frequency</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="reference internal" href="_modules/ecg_qc/sqi_computing/sqi_rr_intervals.html#csqi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.sqi_computing.sqi_rr_intervals.csqi" title="Permalink to this definition"></a></dt>
<dd><p>Variability in the R-R Interval</p>
<p>When an artifact is present, the QRS detector underperforms by either
missing R-peaks or erroneously identifying noisy peaks as R- peaks. The
above two problems will lead to a high degree of variability in the
distribution of R-R intervals;</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p></li>
<li><p><strong>sampling_frequency</strong> (<em>list</em>) – Input ecg sampling frequency</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>c_sqi_score</strong></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="ecg_qc.sqi_computing.sqi_rr_intervals.qsqi">
<span class="sig-prename descclassname"><span class="pre">ecg_qc.sqi_computing.sqi_rr_intervals.</span></span><span class="sig-name descname"><span class="pre">qsqi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_signal</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sampling_frequency</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="reference internal" href="_modules/ecg_qc/sqi_computing/sqi_rr_intervals.html#qsqi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ecg_qc.sqi_computing.sqi_rr_intervals.qsqi" title="Permalink to this definition"></a></dt>
<dd><p>Matching Degree of R Peak Detection</p>
<p>Two R wave detection algorithms are compared with their respective number
of R waves detected.</p>
<ul class="simple">
<li><p>Hamilton</p></li>
<li><p>SWT (Stationary Wavelet Transform)</p></li>
</ul>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ecg_signal</strong> (<em>list</em>) – Input ECG signal</p></li>
<li><p><strong>sampling_frequency</strong> (<em>list</em>) – Input ecg sampling frequency</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>q_sqi_score</strong></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="index.html" class="btn btn-neutral float-left" title="Welcome to ecg_qc’s documentation!" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="references.html" class="btn btn-neutral float-right" title="References" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2021, Aura Healthcare.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>